package cn.cxy.smarttabledemo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.bin.david.form.core.SmartTable
import com.bin.david.form.data.column.Column
import com.bin.david.form.data.table.TableData
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val column1 = Column<String>("姓名", "name")
        val column2 = Column<Int>("年龄", "age")
        val column3 = Column<Long>("更新时间", "time")
        //组合列
        val totalColumn1: Column<*> = Column<Any?>("组合列名", column1, column2)
        var userList = mutableListOf<User>()
        userList.add(User("jerry1", 18, 2019L))
        userList.add(User("jerry2", 19, 2020L))
        userList.add(User("jerry3", 20, 2021L))
        userList.add(User("jerry4", 21, 2022L))
        userList.add(User("jerry5", 22, 2023L))
        //表格数据 datas是需要填充的数据
        val tableData = TableData("表格名", userList, totalColumn1, column3)
        (table as SmartTable<*>).tableData = tableData
    }
}

class User(var name: String, var age: Int, var time: Long)
